package us.mooresr.webtroopmanager.client.place;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;

public class EditVehiclePlace extends Place {
	private Long vehicleId;

	public EditVehiclePlace(Long vehicleId) {
		super();
		this.vehicleId = vehicleId;
	}

	public Long getVehicleId() {
		return vehicleId;
	}

	public void setVehicleId(Long vehicleId) {
		this.vehicleId = vehicleId;
	}
	
	public static class Tokenizer implements PlaceTokenizer<EditVehiclePlace> {

		@Override
		public EditVehiclePlace getPlace(String token) {
			Long vehicleId;
			
			if ((token == null) || token.equals("null")) {
				vehicleId = null;
			} else {
				vehicleId = Long.parseLong(token);
			}
			return new EditVehiclePlace(vehicleId);
		}

		@Override
		public String getToken(EditVehiclePlace place) {
			Long vehicleId = place.getVehicleId();
			
			if (vehicleId == null) {
				return "null";
			} else {
				return vehicleId.toString();
			}
		}
		
	}

}
